package com.example.myapplication.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;


import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.myapplication.R;
import com.example.myapplication.bean.Excerise;

import java.util.ArrayList;
import java.util.List;

public class fragment2 extends Fragment {
    private List<Excerise> exceriseList = new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater,
                             @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fm2,container,false);

        ListView listView = view.findViewById(R.id.list);
        initExc();

        ExceriseAdapter adapter = new ExceriseAdapter(exceriseList, getContext() );
        listView.setAdapter(adapter);
        return view;
    }
    private void initExc(){
        Excerise excerise;
        for (int i = 0;i <20;++i) {
            excerise = new Excerise();
            excerise.id = 1;
            excerise.title = "第"+(i+1)+"章会员制餐厅";
            excerise.color = i%4;
            excerise.url = "https://www.bilibili.com/video/BV1DL411K7zF/";
            exceriseList.add(excerise);
        }


    }
}
